# 请参阅 https://aka.ms/customizecontainer 以了解如何自定义调试容器，以及 Visual Studio 如何使用此 Dockerfile 生成映像以更快地进行调试。

# 此阶段用于在快速模式(默认为调试配置)下从 VS 运行时
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
USER $APP_UID
WORKDIR /app
EXPOSE 8080
EXPOSE 8081


# 此阶段用于生成服务项目
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["src/GEG.NGCRM.Event.Host/GEG.NGCRM.Event.Host.csproj", "src/GEG.NGCRM.Event.Host/"]
COPY ["framework/LJ.EventBus.HornedSerpent.Transport.Kafka/LJ.EventBus.HornedSerpent.Transport.Kafka.csproj", "framework/LJ.EventBus.HornedSerpent.Transport.Kafka/"]
COPY ["framework/LJ.EventBus.HornedSerpent.Transport.Abstractions/LJ.EventBus.HornedSerpent.Transport.Abstractions.csproj", "framework/LJ.EventBus.HornedSerpent.Transport.Abstractions/"]
COPY ["framework/LJ.Abstractions/LJ.Abstractions.csproj", "framework/LJ.Abstractions/"]
COPY ["framework/LJ.EventBus.Data/LJ.EventBus.Data.csproj", "framework/LJ.EventBus.Data/"]
COPY ["framework/LJ.EventBus.HornedSerpent/LJ.EventBus.HornedSerpent.csproj", "framework/LJ.EventBus.HornedSerpent/"]
COPY ["framework/LJ.EventBus.Abstractions/LJ.EventBus.Abstractions.csproj", "framework/LJ.EventBus.Abstractions/"]
COPY ["framework/LJ.IdGenerator.Abstractions/LJ.IdGenerator.Abstractions.csproj", "framework/LJ.IdGenerator.Abstractions/"]
COPY ["framework/LJ.Host.Web/LJ.Host.Web.csproj", "framework/LJ.Host.Web/"]
COPY ["framework/LJ.AspNetCore.Abstractions/LJ.AspNetCore.Abstractions.csproj", "framework/LJ.AspNetCore.Abstractions/"]
COPY ["framework/LJ.Host.Abstractions/LJ.Host.Abstractions.csproj", "framework/LJ.Host.Abstractions/"]
COPY ["framework/LJ.IdGenerator.Sequential/LJ.IdGenerator.Sequential.csproj", "framework/LJ.IdGenerator.Sequential/"]
COPY ["framework/LJ.WebApi.Mvc/LJ.WebApi.Mvc.csproj", "framework/LJ.WebApi.Mvc/"]
COPY ["framework/LJ.WebApi.Abstractions/LJ.WebApi.Abstractions.csproj", "framework/LJ.WebApi.Abstractions/"]
COPY ["framework/LJ.WebApi.Data/LJ.WebApi.Data.csproj", "framework/LJ.WebApi.Data/"]
COPY ["src/GEG.NGCRM.Event.Application/GEG.NGCRM.Event.Application.csproj", "src/GEG.NGCRM.Event.Application/"]
COPY ["src/GEG.NGCRM.Event.Domain/GEG.NGCRM.Event.Domain.csproj", "src/GEG.NGCRM.Event.Domain/"]
COPY ["src/GEG.NGCRM.Event.Domain.Share/GEG.NGCRM.Event.Domain.Share.csproj", "src/GEG.NGCRM.Event.Domain.Share/"]
RUN dotnet restore "./src/GEG.NGCRM.Event.Host/GEG.NGCRM.Event.Host.csproj"
COPY . .
WORKDIR "/src/src/GEG.NGCRM.Event.Host"
RUN dotnet build "./GEG.NGCRM.Event.Host.csproj" -c $BUILD_CONFIGURATION -o /app/build

# 此阶段用于发布要复制到最终阶段的服务项目
FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./GEG.NGCRM.Event.Host.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false

# 此阶段在生产中使用，或在常规模式下从 VS 运行时使用(在不使用调试配置时为默认值)
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "GEG.NGCRM.Event.Host.dll"]